home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-13 / xvisrc.zip / I286.ASM < prev    next >
Assembly Source File  |  1992-07-28  |  2KB  |  73 lines

  1. ; Copyright (c) 1990,1991,1992 Chris and John Downey
  2. .286P
  3.  
  4. I286_TEXT    segment word public 'CODE'
  5.         db    "@(#)i286.asm    2.1 (Chris & John Downey) 7/29/92"
  6.         db    0
  7. ;***
  8. ;
  9. ; program name:
  10. ;    xvi
  11. ; function:
  12. ;    PD version of UNIX "vi" editor, with extensions.
  13. ; module name:
  14. ;    i286.asm
  15. ; module function:
  16. ;    Low-level 80286-specific routines for OS/2 version.
  17. ; history:
  18. ;    STEVIE - ST Editor for VI Enthusiasts, Version 3.10
  19. ;    Originally by Tim Thompson (twitch!tjt)
  20. ;    Extensive modifications by Tony Andrews (onecom!wldrdg!tony)
  21. ;    Heavily modified by Chris & John Downey
  22. ;
  23. ;***
  24.         public    _es0
  25.         public    _newstack
  26. ;
  27. ; void far es0(void);
  28. ;
  29. ; Set the ES register to 0. Microsoft say this should be done
  30. ; before calling the OS/2 DosCreateThread() system call but, as
  31. ; far as I can see, they don't provide any C library function or
  32. ; compiler directive or any other easy way of doing it. So, if
  33. ; you want to write multi-thread code for OS/2, you just have to
  34. ; be an assembler hacker.
  35. ;
  36. _es0        proc    far
  37.         xor    ax, ax
  38.         mov    es, ax
  39.         ret
  40. _es0        endp
  41.  
  42. ;
  43. ; unsigned char far * far newstack (int sub);
  44. ;
  45. ; This is utterly disgusting, but unavoidable. The fault lies
  46. ; with the design of OS/2, & the lack of provision for multiple
  47. ; stacks in Microsoft's high-level language products.
  48. ;
  49. ; We need the provision for multiple stacks because we are
  50. ; running multiple threads, but some Microsoft library functions
  51. ; are evidently compiled with stack probes, which give spurious
  52. ; stack overflow errors if we use multiple stacks. So we just
  53. ; use some space at the bottom of our default (48 kb) stack. The
  54. ; return value we want here is the top of the new stack, & we
  55. ; obtain it simply by subtracting the sub parameter from the
  56. ; stack pointer.
  57. ;
  58. _newstack    proc    far
  59.         mov    bx, sp
  60.         ;
  61.         ; Return offset in AX.
  62.         ;
  63.         mov    ax, sp
  64.         sub    ax, word ptr ss:[bx + 4]
  65.         ;
  66.         ; Return stack segment in DX.
  67.         ;
  68.         mov    dx, ss
  69.         ret
  70. _newstack    endp
  71. I286_TEXT    ends
  72.         end
  73.